from forest.registry import register_tool
import os

@register_tool('system.truncate')
def truncate(outfile, size):
    '''Call os.ftruncate to truncate a file to the given size.'''
    fobj = open(outfile, "a")
    os.ftruncate(fobj.fileno(), size)
